package al240searchMatrix;

public class SearchMatrix240 {

    public static  boolean searchMatrix(int[][] matrix, int target) {

        int i =0;
        int j = matrix[0].length-1;

        if (matrix[i][j]==target)
            return true;
        while (i<matrix.length && j >=0){
            if (matrix[i][j] == target)
                return true;
            if (matrix[i][j] < target){
                i++;
            }else {
                j--;
            }

        }

        return false;
    }

    public static void main(String[] args) {
        int[][] nums = {{5},{6}};
        System.out.println(searchMatrix(nums,6));
    }
}
